/*   1:    */ package org.jetbrains.jps.model.java.impl;
/*   2:    */ 
/*   3:    */

import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.java.*;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsSdkDependency;
import org.jetbrains.jps.model.module.impl.JpsDependenciesEnumeratorBase;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */ 
/*  20:    */ public class JpsJavaDependenciesEnumeratorImpl
/*  21:    */   extends JpsDependenciesEnumeratorBase<JpsJavaDependenciesEnumeratorImpl>
/*  22:    */   implements JpsJavaDependenciesEnumerator
/*  23:    */ {
/*  24:    */   private boolean e;
/*  25:    */   private boolean f;
/*  26:    */   private boolean g;
/*  27:    */   private boolean h;
/*  28:    */   private boolean i;
/*  29:    */   private JpsJavaClasspathKind j;
/*  30:    */   private final List<JpsJavaDependenciesEnumerationHandler> k;
/*  31:    */   
/*  32:    */   public JpsJavaDependenciesEnumeratorImpl(Collection<JpsModule> paramCollection)
/*  33:    */   {
/*  34: 43 */     super(paramCollection);
/*  35: 44 */     List localList = JpsJavaDependenciesEnumerationHandler.createHandlers(paramCollection);
/*  36: 45 */     this.k = (localList != null ? localList : Collections.emptyList());
/*  37:    */   }
/*  38:    */   
/*  39:    */   @NotNull
/*  40:    */   public JpsJavaDependenciesEnumerator productionOnly()
/*  41:    */   {
/*  42: 51 */     this.e = true;
/*  43: 52 */     if (this == null) {
/*  44: 52 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "productionOnly" }));
/*  45:    */     }
/*  46: 52 */     return this;
/*  47:    */   }
/*  48:    */   
/*  49:    */   @NotNull
/*  50:    */   public JpsJavaDependenciesEnumerator compileOnly()
/*  51:    */   {
/*  52: 58 */     this.g = true;
/*  53: 59 */     if (this == null) {
/*  54: 59 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "compileOnly" }));
/*  55:    */     }
/*  56: 59 */     return this;
/*  57:    */   }
/*  58:    */   
/*  59:    */   @NotNull
/*  60:    */   public JpsJavaDependenciesEnumerator runtimeOnly()
/*  61:    */   {
/*  62: 65 */     this.f = true;
/*  63: 66 */     if (this == null) {
/*  64: 66 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "runtimeOnly" }));
/*  65:    */     }
/*  66: 66 */     return this;
/*  67:    */   }
/*  68:    */   
/*  69:    */   @NotNull
/*  70:    */   public JpsJavaDependenciesEnumerator exportedOnly()
/*  71:    */   {
/*  72: 72 */     if (this.myRecursively) {
/*  73: 73 */       this.i = true;
/*  74:    */     } else {
/*  75: 76 */       this.h = true;
/*  76:    */     }
/*  77: 78 */     if (this == null) {
/*  78: 78 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "exportedOnly" }));
/*  79:    */     }
/*  80: 78 */     return this;
/*  81:    */   }
/*  82:    */   
/*  83:    */   @NotNull
/*  84:    */   public JpsJavaDependenciesEnumerator recursivelyExportedOnly()
/*  85:    */   {
/*  86: 84 */     JpsJavaDependenciesEnumerator tmp10_7 = ((JpsJavaDependenciesEnumeratorImpl)recursively()).exportedOnly();
/*  87: 84 */     if (tmp10_7 == null) {
/*  88: 84 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "recursivelyExportedOnly" }));
/*  89:    */     }
/*  90: 84 */     return tmp10_7;
/*  91:    */   }
/*  92:    */   
/*  93:    */   @NotNull
/*  94:    */   public JpsJavaDependenciesEnumerator includedIn(@NotNull JpsJavaClasspathKind paramJpsJavaClasspathKind)
/*  95:    */   {
/*  96: 90 */     if (paramJpsJavaClasspathKind == null) {
/*  97: 90 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "includedIn" }));
/*  98:    */     }
/*  99: 90 */     this.j = paramJpsJavaClasspathKind;
/* 100: 91 */     if (this == null) {
/* 101: 91 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "includedIn" }));
/* 102:    */     }
/* 103: 91 */     return this;
/* 104:    */   }
/* 105:    */   
/* 106:    */   @NotNull
/* 107:    */   public JpsJavaDependenciesRootsEnumerator classes()
/* 108:    */   {
/* 109: 97 */     void tmp11_8 = new JpsJavaDependenciesRootsEnumeratorImpl(this, JpsOrderRootType.COMPILED);
/* 110: 97 */     if (tmp11_8 == null) {
/* 111: 97 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "classes" }));
/* 112:    */     }
/* 113: 97 */     return tmp11_8;
/* 114:    */   }
/* 115:    */   
/* 116:    */   @NotNull
/* 117:    */   public JpsJavaDependenciesRootsEnumerator sources()
/* 118:    */   {
/* 119:103 */     void tmp11_8 = new JpsJavaDependenciesRootsEnumeratorImpl(this, JpsOrderRootType.SOURCES);
/* 120:103 */     if (tmp11_8 == null) {
/* 121:103 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "sources" }));
/* 122:    */     }
/* 123:103 */     return tmp11_8;
/* 124:    */   }
/* 125:    */   
/* 126:    */   @NotNull
/* 127:    */   public JpsJavaDependenciesRootsEnumerator annotations()
/* 128:    */   {
/* 129:109 */     void tmp11_8 = new JpsJavaDependenciesRootsEnumeratorImpl(this, JpsAnnotationRootType.INSTANCE);
/* 130:109 */     if (tmp11_8 == null) {
/* 131:109 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/java/impl/JpsJavaDependenciesEnumeratorImpl", "annotations" }));
/* 132:    */     }
/* 133:109 */     return tmp11_8;
/* 134:    */   }
/* 135:    */   
/* 136:    */   protected JpsJavaDependenciesEnumeratorImpl self()
/* 137:    */   {
/* 138:114 */     return this;
/* 139:    */   }
/* 140:    */   
/* 141:    */   protected boolean shouldProcessDependenciesRecursively()
/* 142:    */   {
/* 143:119 */     return JpsJavaDependenciesEnumerationHandler.shouldProcessDependenciesRecursively(this.k);
/* 144:    */   }
/* 145:    */   
/* 146:    */   protected boolean shouldProcess(JpsModule paramJpsModule, JpsDependencyElement paramJpsDependencyElement)
/* 147:    */   {
/* 148:124 */     boolean bool = !(paramJpsDependencyElement instanceof JpsSdkDependency);
/* 149:125 */     JpsJavaDependencyExtension localJpsJavaDependencyExtension = JpsJavaExtensionService.getInstance().getDependencyExtension(paramJpsDependencyElement);
/* 150:126 */     if (localJpsJavaDependencyExtension != null)
/* 151:    */     {
/* 152:127 */       bool = localJpsJavaDependencyExtension.isExported();
/* 153:128 */       JpsJavaDependencyScope localJpsJavaDependencyScope = localJpsJavaDependencyExtension.getScope();
/* 154:129 */       int m = (localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.TEST_COMPILE)) || ((localJpsJavaDependencyScope == JpsJavaDependencyScope.RUNTIME) && (shouldAddRuntimeDependenciesToTestCompilationClasspath())) ? 1 : 0;
/* 155:131 */       if (((this.g) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_COMPILE)) && (m == 0)) || ((this.f) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME)) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.TEST_RUNTIME))) || ((this.j != null) && (!localJpsJavaDependencyScope.isIncludedIn(this.j)) && ((this.j != JpsJavaClasspathKind.TEST_COMPILE) || (m == 0)))) {
/* 156:134 */         return false;
/* 157:    */       }
/* 158:136 */       if ((this.e) && (
/* 159:137 */         ((!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_COMPILE)) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME))) || ((this.g) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_COMPILE))) || ((this.f) && (!localJpsJavaDependencyScope.isIncludedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME))))) {
/* 160:140 */         return false;
/* 161:    */       }
/* 162:    */     }
/* 163:144 */     if (!bool)
/* 164:    */     {
/* 165:145 */       if (this.h) {
/* 166:145 */         return false;
/* 167:    */       }
/* 168:146 */       if ((this.i) && (!isEnumerationRootModule(paramJpsModule))) {
/* 169:146 */         return false;
/* 170:    */       }
/* 171:    */     }
/* 172:148 */     return true;
/* 173:    */   }
/* 174:    */   
/* 175:    */   public boolean isProductionOnly()
/* 176:    */   {
/* 177:152 */     return (this.e) || (this.j == JpsJavaClasspathKind.PRODUCTION_RUNTIME) || (this.j == JpsJavaClasspathKind.PRODUCTION_COMPILE);
/* 178:    */   }
/* 179:    */   
/* 180:    */   public boolean isProductionOnTests(JpsDependencyElement paramJpsDependencyElement)
/* 181:    */   {
/* 182:156 */     for (JpsJavaDependenciesEnumerationHandler localJpsJavaDependenciesEnumerationHandler : this.k) {
/* 183:157 */       if (localJpsJavaDependenciesEnumerationHandler.isProductionOnTestsDependency(paramJpsDependencyElement)) {
/* 184:158 */         return true;
/* 185:    */       }
/* 186:    */     }
/* 187:161 */     return false;
/* 188:    */   }
/* 189:    */   
/* 190:    */   public boolean shouldIncludeTestsFromDependentModulesToTestClasspath()
/* 191:    */   {
/* 192:165 */     for (JpsJavaDependenciesEnumerationHandler localJpsJavaDependenciesEnumerationHandler : this.k) {
/* 193:166 */       if (!localJpsJavaDependenciesEnumerationHandler.shouldIncludeTestsFromDependentModulesToTestClasspath()) {
/* 194:167 */         return false;
/* 195:    */       }
/* 196:    */     }
/* 197:170 */     return true;
/* 198:    */   }
/* 199:    */   
/* 200:    */   public boolean shouldAddRuntimeDependenciesToTestCompilationClasspath()
/* 201:    */   {
/* 202:174 */     for (JpsJavaDependenciesEnumerationHandler localJpsJavaDependenciesEnumerationHandler : this.k) {
/* 203:175 */       if (localJpsJavaDependenciesEnumerationHandler.shouldAddRuntimeDependenciesToTestCompilationClasspath()) {
/* 204:176 */         return true;
/* 205:    */       }
/* 206:    */     }
/* 207:179 */     return false;
/* 208:    */   }
/* 209:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.java.impl.JpsJavaDependenciesEnumeratorImpl

 * JD-Core Version:    0.7.0.1

 */